package edu.flying.panda.taskmanager;

import android.util.Log;

	

public class Date {
	
	private int year;
	private int month;
	private int day;
	private int hour;
	private int minute;
	
	public Date(){
		year = 0;
		month = 0;
		day = 0;
		hour = 0;
		minute = 0; 
	}
	
	public Date(int year, int month, int day, int hour, int minute){
		this.year = year;
		this.month = month;
		this.day = day;
		this.hour = hour;
		this.minute = minute;		
	}
	
	public Date(String date){
		String[] dates = date.split(":");
		
		year = Integer.parseInt(dates[0]);
		month = Integer.parseInt(dates[1]);
		day = Integer.parseInt(dates[2]);
		hour = Integer.parseInt(dates[3]);
		minute = Integer.parseInt(dates[4]);
		
	}
	
	/**
	 * a.compareTo(d)
	 * @param date d
	 * @return -1  if  a is before d, 1 if a is after d, 0 if dates equal 
	 */
	public int compareTo(Date d){
		//a before d
		int Ireturn = 0;
		
		if (year < d.getYear()){
			Log.d("compare", "1");
			Ireturn = -1;
		}else if (year > d.getYear()){
			Log.d("compare", "2");
			Ireturn = 1;
		}else if (month < d.getMonth()){
			Log.d("compare", "3");
			Ireturn = -1;
		}else if (month >d.getMonth()){
			Log.d("compare", "4");
			Ireturn = 1;
		}else if (day < d.getDay()){
			Log.d("compare", "5");
			Ireturn = -1;
		}else if (day > d.getDay()){
			Log.d("compare", "6");
			Ireturn = 1;
		}else if (hour < d.getHour()){
			Log.d("compare", "7");
			Ireturn = -1;
		}else if (hour > d.getDay() ){
			Log.d("compare", "8");
			Ireturn = 1;
		}else if (minute < d.getMinute()){
			Log.d("compare", "9");
			Ireturn = -1;
		}else if (minute > d.getMinute()){
			Log.d("compare", "10");
			Ireturn = 1;
		}
		
		return Ireturn;
	}

	public int getYear() {
		return year;
	}

	public void setYear(int year) {
		this.year = year;
	}

	public int getMonth() {
		return month;
	}

	public void setMonth(int month) {
		this.month = month;
	}

	public int getDay() {
		return day;
	}

	public void setDay(int day) {
		this.day = day;
	}

	public int getHour() {
		return hour;
	}

	public void setHour(int hour) {
		this.hour = hour;
	}

	public int getMinute() {
		return minute;
	}

	public void setMinute(int minute) {
		this.minute = minute;
	}
	
	public String toString(){
		return Integer.toString(year)+":"+Integer.toString(month)+":"+Integer.toString(day)+":"+
				Integer.toString(hour)+":"+Integer.toString(minute);
	}

}
